//
//  CellViewController.m
//  TheAddressBookDemo
//
//  Created by 郭颢源 on 2020/10/16.
//  Copyright © 2020 YangLei. All rights reserved.
//

#import "CellViewController.h"
#import "CYTabCell.h"

@interface CellViewController ()
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *array;
@end

@implementation CellViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //数据源
    _array = @[@"今天的天气真好，今天的天气真好，今天的天气真好，今天的天气真好，今天的天气真好", @"今天的天气真好，今天的天气真好", @"今天的天气真好，今天的天气真好，今天的天气真好", @"今天的天气真好"];
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerClass:[CYTabCell class] forCellReuseIdentifier:@"CYTabCell"];
    [self.view addSubview:_tableView];
    
}

//记住千万不要实现 tableView 的 cell 高度代理
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CYTabCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CYTabCell"];
    cell.str = _array[indexPath.row];
    return cell;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
